home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
BYACC__
/
DERIVES.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-19
|
904b
|
63 lines
#include <stdio.h>
#include "defs.h"
#include "new.h"
#include "gram.h"
set_derives()
{
register int i, k;
register int lhs;
register short *rules;
derives = NEW2(nsyms, short *);
rules = NEW2(nvars + nrules, short);
k = 0;
for (lhs = start_symbol; lhs < nsyms; lhs++)
{
derives[lhs] = rules + k;
for (i = 0; i < nrules; i++)
{
if (rlhs[i] == lhs)
{
rules[k] = i;
k++;
}
}
rules[k] = -1;
k++;
}
#ifdef DEBUG
print_derives();
#endif
}
free_derives()
{
FREE(derives[start_symbol]);
FREE(derives);
}
#ifdef DEBUG
print_derives()
{
register int i;
register short *sp;
printf("\nDERIVES\n\n");
for (i = start_symbol; i < nsyms; i++)
{
printf("%s derives ", symbol_name[i]);
for (sp = derives[i]; *sp >= 0; sp++)
{
printf(" %d", *sp);
}
putchar('\n');
}
putchar('\n');
}
#endif